<?php
//Iskysoft产品类
//用于写产品的相关替换函数
include(dirname(__FILE__).'/../public/public_products.php');

class IskysoftProducts extends PublicProducts  {

	var $db, $video_tag, $web_fage;
	function __construct(){
		$this->db = $GLOBALS['db'];
		$this->web_fage = 8;
		parent::__construct( $this->db, $this->web_fage );
	}
	
	/**
	 * 比较或视频
	 * */
	function compareOrVideo( $get ){
		$id = $get['产品ID'];
		$str = '';
		$sql = "SELECT url FROM Table_170 WHERE Field_21860 IN (
					SELECT Field_21671 FROM Table_137 WHERE Field_21669 = {$id}
				)";
		$url = $this->db->getOne( $sql );
		$url = url_replace( $get['url'], $url, 'iskysoft');
		
		if( $url ){
			$row = $this->productInfo( $id );
			$os = $row['product_os'];
			
			$str = '<div class="col1"><a class="compare" href="'.$url.'">
					<img src="http://www.iskysoft.com/images/compare-icon.png" alt="Compare" class="compare-icon" />
					<span>Compare<br/>'.$os.' Products</span></a></div>';

		//没有比较页面信息，则取视频信息
		}else{
				$sql = "SELECT p.product_video_promo FROM won_product won_p 
						LEFT JOIN product p ON p.product_id = won_p.won_product_id
						WHERE id = {$id}";
				$row = $this->db->getOne( $sql );
			
				if( $row ){
					$str = '<div class="col1"><div class="flash videoDemo" href="#video-demo">
							<img src="http://www.iskysoft.com/images/screencast/vcm-s.png" />
							<span>Watch the<br>Screencast</span></div></div>';
					//作用：当此处显示视频时，右侧则不显示视频
					$this->video_tag = 'VideoOff';
				}
			}
		return $str;
	}
	
	/**
	 * 快捷链接
	 * */
	function quickLinks( $get ){
		$id = $get['产品ID'];
		$url = $get['url'];
		
		$sql_guide = "SELECT url FROM Table_140 WHERE Field_21690 = {$id}";
		$url_guide = $this->db->getOne($sql_guide);
		$url_guide = url_replace($url,$url_guide ,'iskysoft');
				
		$sql_tech = "SELECT url FROM Table_141 WHERE Field_21695 = {$id}";
		$url_tech = $this->db->getOne($sql_tech);
		$url_tech = url_replace($url,$url_tech ,'iskysoft');
		
		//循环出可选属性
		$sql_p_att = "SELECT won_attributes_id FROM won_product WHERE id = {$id}";
		$att_str = $this->db->getOne($sql_p_att);	
		
		if( $att_str ){
			$sql = "SELECT att.name,att.id,tab.url FROM Table_164 tab 
					LEFT JOIN product_attributes att ON tab.Field_21808 = att.name 
					WHERE tab.Field_21807 = {$id} AND FIND_IN_SET(att.id,'{$att_str}')
					ORDER BY tab.Field_21809 DESC";
			$rows = $this->db->getAll( $sql );
			
			$str_t = '';
			foreach( $rows as $row ){
				$name = trim($row['name']);
				//重新命名				
				switch( $name ){
					case 'What\'s new':$name = 'What\'s new in this version';break;
				}
				$u = url_replace($url,$row['url'],'iskysoft');
				$str_t .= '<li><a href="'.$u.'">'.$name.'</a></li>';
			}	
		}
		
		$str = '<div class="side">
				<h4>Quick Links</h4>
				<div class="inside">
					<ul>';
				if( $url_guide ) $str .= '<li><a href="'.$url_guide.'">Step-by-step user guide</a></li>';
				if( $url_tech ) $str .= '<li><a href="'.$url_tech.'">Technical specifications</a></li>';
					$str .= $str_t.
					'<li><a href="http://www.iskysoft.com/purchase/licence.html">Software license types</a></li>
					<li><a href="http://www.iskysoft.com/join-newsletter/subscribe.html">Join iSkysoft newsletter</a></li>
					<li><a class="end" href="http://support.iskysoft.com/index.php?submod=ticket&method=onlineform" target="_blank">Ask a question</a></li>
					</ul>
				</div>
				</div>';	
		return $str;
	}

	
	/**
	 * 去品牌产品名称
	 * */
	function productNameNoBrand( $get ){
		$name = trim($get['产品名称']);
		if( substr(strtolower( $name ), 0, 8) == 'iskysoft' ) $name = substr( $name, 8 );
		return $name;
	}
	
	/**
	 * 产品页面地址
	 * */
	function productUrl( $get ){
		$id = $get['产品ID'];

		$sql = "SELECT url FROM Table_137 WHERE Field_21669 = {$id}";
		$url = $this->db->getOne( $sql );
		if( !$url ){
			$sql = "SELECT url FROM Table_147 WHERE Field_21726 = {$id}";
			$url = $this->db->getOne( $sql );
		}
		
		$url = str_replace('/iskysoft.com/httpdocs','http://www.iskysoft.com',$url);
		return $url;
	}
	/**
	* 根据产品id产品切换列表
	*/
	function switchPage( $get )
	{
		$id = $get['产品ID'];
		$url = $get['url'];
		$str = '';

		//Features,User Guide,Reference固定显示不用判断				
		//Features
		$sql = "SELECT url FROM Table_137 WHERE Field_21669 = {$id}";
		$p_url = $this->db->getOne($sql);	
		
		//单页
		if( empty($p_url) ){
			$sql = "SELECT url FROM Table_147 WHERE Field_21726 = {$id}";
			$p_url = $this->db->getOne( $sql );
		}
		
		$p_url = url_replace( $url, $p_url, 'iskysoft');
		$str .= '<li><a href="'.$p_url.'" id="tab_feature">Features</a></li>';

		//User Guide
		$sql_guide = "SELECT url FROM Table_140 WHERE Field_21690 = {$id}";
		$url_guide = $this->db->getOne($sql_guide);
		$url_guide = url_replace($url,$url_guide ,'iskysoft');
		$str .= '<li><a href="'.$url_guide.'" id="tab_guide">User Guide</a></li>';
		
		//Reference
		$sql_ref = "SELECT url FROM Table_141 WHERE Field_21695 = {$id}";
		$url_ref = $this->db->getOne($sql_ref);
		$url_ref = url_replace($url,$url_ref ,'iskysoft');
		$str .= '<li><a href="'.$url_ref.'" id="tab_reference">Reference</a></li>';
		
		//切换项
		$sql_p_att = "SELECT won_attributes_id FROM won_product WHERE id = {$id}";
		$att_str = $this->db->getOne($sql_p_att);	

		if( $att_str ){
			
			//what's new
			$sql = "SELECT url FROM Table_138 WHERE Field_21676 = {$id}";
			$w_url = $this->db->getOne( $sql );
			if( $w_url ){
				$w_url = url_replace($url, $w_url ,'iskysoft');
			    $str .= '<li><a href="'.$w_url.'">What\'s new</a></li>';
			}

			//其它切换项
			$sql = "SELECT att.name,att.id,tab.url FROM Table_164 tab 
					LEFT JOIN product_attributes att ON tab.Field_21808 = att.name 
					WHERE tab.Field_21807 = {$id} AND FIND_IN_SET(att.id,'{$att_str}') AND tab.url != ''
					ORDER BY tab.Field_21809 DESC";
			$rows = $this->db->getAll( $sql );
			
			foreach( $rows as $row ){
				$name = trim($row['name']);
				$row['url'] = url_replace($url, $row['url'] ,'iskysoft');
			    $str .= '<li><a href="'.$row['url'].'">'.$name.'</a></li>';
			}
		}
		
		//产品评论
		$sql = "SELECT url FROM Table_193 WHERE Field_22043 = {$id}";
		$url_r = $this->db->getOne($sql);
		if( $url_r ){
			$url_r = url_replace($url,$url_r ,'iskysoft');
			$str .= '<li><a href="'.$url_r.'" id="tab_review">Reviews</a></li>';
		}

		return $str; 
	}
	
	/**
	* 产品下载跳转地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productDownloadJumpUrl($get) {

		$id = (int) $get['产品ID'];
		$sql = "SELECT url FROM Table_197 WHERE Field_22071 = {$id} LIMIT 1 ";
		$url = $this->db->getOne($sql);
		
		if (!empty($url)) {
		 	return str_replace(array('/iskysoft.com/httpdocs', 'index.html'), array('http://www.iskysoft.com', ''), $url);
		} else {
			return '';
		}
		
		
	}
	
	/**
	* 根据产品id取得下载与免费上
	*/
	function downloadAndPriceTop( $get )
	{
		$id = $get['产品ID'];
		$str = '';
		$sql = "SELECT p.product_isfree, p.product_id, p.product_name, p.product_type, won_p.giveaway, won_p.getcodeurl FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = {$id}";
		$row = $this->db->getOneRs( $sql );

		$version = get_sale_version($row['product_id']);
		
		$download_jump_url = $version['download_url'];
		
		


		$sql_168 = "SELECT url FROM Table_168 WHERE Field_21835 = {$id}";
		$buy_url = $this->db->getOne($sql_168);
		
		//产品单页
		if(empty($buy_url)){
			$sql = "SELECT url FROM Table_147 WHERE Field_21726 = {$id}";
			$buy_url = $this->db->getOne($sql);
		}
		$buy_url = url_replace($get['url'],$buy_url ,'iskysoft');
		
		//免费
		if( $row['product_isfree'] == 1){
			$str = '<li class="free-try"><a onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);
					_gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;" rel="nofollow" href="'.$download_jump_url.'">Download</a></li>';
		}else{
			//试用
			if($row['product_type'] == 1){
				$str = '<li class="try"><a href="'.$download_jump_url.'" onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);
				_gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;">Try</a></li>';
			}
			//促销
			//if($row['giveaway'] == 1){
			//}else{
				//购买
				$str .= '<li class="buy"><a href="'.$buy_url.'" onClick="_gaq.push([\'_trackEvent\', \'IS/'.$row['product_name'].'\', \'Buy\', document.location.href+\'/top\']);">Buy</a></li>';
			//}
		}

		return $str;
	}
		
		
	/**
	* 根据产品id取得下载与免费中
	*/
	function downloadAndPriceMid( $get )
	{
		$id = $get['产品ID'];
		
		$str = $old = $year_str = $new = '';
		
		$sql = "SELECT p.product_isfree, p.product_id, p.product_type,p.product_brand,p.product_name,p.product_version ,p.product_is_year_charge,won_p.giveaway,won_p.getcodeurl
				FROM won_product won_p LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = {$id}";
		$row = $this->db->getOneRs($sql);
		
		$version = get_sale_version($row['product_id']);
		$row['product_version'] = $version['version_name'];
		$row['product_size'] = $version['product_size'];
		
		$download_jump_url = $version['download_url'];
		
		
		$price_arr = get_price( $row['product_id'] );
		$new = $price_arr['curr'];
		if( $row['product_is_year_charge'] ) $year_str = '/year';
		if( $price_arr['unique'] ) $old = '$'.$price_arr['old'];
					
		$sql = "SELECT url FROM Table_168 WHERE Field_21835 = {$id}";
		$buy_url = $this->db->getOne($sql);
		$buy_url = url_replace($get['url'],$buy_url ,'iskysoft');
		
		//有What's new的话则加连接
		$sql = "SELECT url FROM Table_164 WHERE Field_21807 = {$id} AND Field_21808 = 'What\'s new'";
		$url = $this->db->getOne( $sql );
		
		if( $url ){
			$url = url_replace( $get['url'], $url ,'iskysoft');
			//$version_href = '<a href="'.$url.'">Version '.$row['product_version'].'</a>';
			$version_href = 'Version '.$row['product_version'];
		}else{
			$version_href = 'Version '.$row['product_version'];
		}
		
		if( $id == 141 ){
			$v_href = '<p><a href="http://www.iskysoft.com/video-converter-mac/older-version.html">Click here for PPC version</a></p>';
		}elseif( $id == 142 ){
			$v_href = '<p><a href="http://www.iskysoft.com/dvd-ripper-mac/older-version.html">Click here for PPC version</a></p>';
		}else{
			$v_href = '';
		}
		
		//免费
		if($row['product_isfree'] == 1){
			$str .= '<div class="col3">';
			$str .= '<a class="btnDownload" rel="nofollow" href="'.$download_jump_url.'" onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);_gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;">'.$version_href.'</a>
			<p><img src="http://images.wondershare.com/style/images0328/pro_06.png" /> Secure Download</p>';
			
          	//$str .= '<p>'.$version_href.' <span class="price">('.$row['product_size'].' MB)</span></p>';
          	//$str .= $v_href;
			$str .= '</div>';
		}else{
			//试用
			if($row['product_type'] == 1){
				$str .= '<div class="col3">';
				$str .= '<a rel="nofollow" class="btnFree" href="'.$download_jump_url.'" onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);_gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;">'.$version_href.'</a>
				<p><img src="http://images.wondershare.com/style/images0328/pro_06.png" /> Secure Download</p>';
          		//$str .= '<p>'.$version_href.' <span class="price">('.$row['product_size'].' MB)</span></p>';
          		//$str .= $v_href;
				$str .= '</div>';
			}
			//促销
			//if($row['giveaway'] == 1){
			//}else{
				//购买
				$str .= '<div class="col4">';
				//$str .= '<p class="price"><s>'.$old.'</s> $'.$new.$year_str.'</p>';
				$str .= '<a href="'.$buy_url.'" class="btnBuy" onClick="_gaq.push([\'_trackEvent\', \'IS/'.$row['product_name'].'\', \'Buy\', document.location.pathname+\'/mid\']);"><s>'.$old.'</s> Only $'.$new.$year_str.'</a>
				<p><img src="http://images.wondershare.com/style/images0328/pro_08.png" /> 90 Days Money Back Guarantee</p>';
				$str .= '</div>';
			//}
		}

		return $str;
	}
	
	
	/**
	* 根据产品id取得下载与免费下
	*/
	function downloadAndPriceBtn( $get )
	{
		$id = $get['产品ID'];
		
		$sql = "SELECT p.product_isfree, p.product_id, p.product_type,p.product_brand,p.product_name,p.product_version,p.product_is_year_charge,won_p.giveaway,won_p.getcodeurl,won_p.ad_guide
				FROM won_product won_p LEFT JOIN product p ON p.product_id = won_p.won_product_id
				WHERE won_p.id = {$id}";
		$row = $this->db->getOneRs( $sql );
		
		$version = get_sale_version($row['product_id']);
		
		$download_jump_url = $version['download_url'];
		

		$row['product_version'] = $version['version_name'];
		
		
		//有广告则不显示what's next
		$ad = trim($get['底部广告']);
		if( $ad ){
			return '<div id="advanced">'.$ad.'</div>';
		}
		
		$sql_168 = "SELECT url FROM Table_168 WHERE Field_21835 = {$id}";
		$buy_url = $this->db->getOne($sql_168);
		
		//产品单页
		if(empty($buy_url)){
			$sql = "SELECT url FROM Table_147 WHERE Field_21726 = {$id}";
			$buy_url = $this->db->getOne($sql);
		}
		$buy_url = url_replace($get['url'],$buy_url ,'iskysoft');

		$str = '<div id="what-next">
				<h4>What\'s next?</h4>
				<p>'.$row['ad_guide'].'</p>
		        <ul>';
		//免费
		if($row['product_isfree'] == 1){
			$str .= '<li><a id="down" href="'.$download_jump_url.'" onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);_gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;" style="margin-left:60px;">Download</a></li>';
		}else{
			//试用
			if($row['product_type'] == 1) $str .= '<li><a id="down" href="'.$download_jump_url.'" onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);_gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;">Free Trial</a></li>';
			//促销
			//if($row['giveaway'] == 1){
			//	$str .= '<li></li>';
			//}else{
				//购买
				$str .= '<li><a class="buy" href="'.$buy_url.'" onClick="_gaq.push([\'_trackEvent\', \'IS/'.$row['product_name'].'\', \'buy\', document.location.href+\'/foot\']);">Buy Now</a></li>';
			//}
		}	
		$str .= '</ul></div>';
		return  $str;
	}
	
	/**
	* 根据产品id取得产品头部配图
	*/
	function topImage( $get )
	{	
		$id = $get['产品ID'];
		$web_type = $get['web_type'];
		
		$sql = "SELECT top_image FROM won_product WHERE ID = {$id}";
		$url = $this->db->getOne( $sql );
				
		$row = $this->productInfo( $id );
		$product_box_big = $row['product_box_big'];
		$os = $row['product_os'];
		
		$lion_url = $this->lionPicUrl( $get );
		
		$str = '<img class="interface" src="'.$url.'" alt="'.$this->productNameNoBrand( $get ).'" width="330" height="210" />';
		if( $product_box_big ) $str .= '<img class="icon" src="'.$product_box_big.'" >';

		if( $os == 'Win' ){
			if( in_array( $id, array(151,131) ) ){//5x
				$str .= '<a href="http://www.iskysoft.com/performance-nvidia-cuda.html">
						<img class="icon2" alt="Lion icon" src="http://www.iskysoft.com/images/win/5x-faster_3.png" /></a>';
			}elseif( in_array( $id, array(133,132,130) ) ){//6x
				$str .= '<a href="http://www.iskysoft.com/other/cpu-optimization.html">
						<img class="icon2" alt="Lion icon" src="http://www.iskysoft.com/images/win/6x-faster.png" /></a>';
			}	
		}else{
			if( !in_array( $id, array(144, 145, 137) )) {
				$str .= '<img class="icon2" alt="Lion icon" src="http://www.iskysoft.com/other/image/lion.png" />';
			}
		}
	
		return $str;
	}

	/**
	 * 系统支持长
	 * */
	function sysSupportLong( $get ){	
		$id = $get['产品ID'];
		
		$str = '';
		$sql = "SELECT p.product_os, p.product_support_content FROM won_product won_p LEFT JOIN product p ON p.product_id = won_p.won_product_id WHERE won_p.id = {$id}";
		$data = $this->db->getOneRs($sql);
		if( empty( $data ) ) return '';

		$str .= '<div class="col2">';
		$str .= '<p class="title"><img src="http://www.iskysoft.com/images/'.($data['product_os']=='Win'?'windows':'icon-for-mac').'.png" width="16" height="17" alt="for '.($data['product_os']=='Win'?'win':'mac').'" />System Requirements</p>';	
		$str .= $data['product_support_content'] ? ''.$data['product_support_content'].'' : '';
		$str .= '</div>';

		return $str;
	}
	
	/**
	 * feature功能点
	 * */
	function keyFeature( $get ){
		$id = $get['产品ID'];
		
		$str = '';
		$sql = "SELECT f.feature_title,f.feature_intro,f.feature_pic_min,f.feature_pic_max, f.feature_id
				FROM feature f LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id
				WHERE f.feature_type = 0 AND f.is_delete = 0 AND won_p.id = {$id} ORDER BY f.feature_order ASC";
		$result = $this->db->getAll($sql);
		
		foreach( $result as $k=>$v ){
			$str .= '<div class="grid'.(($k+1)%2==0?' last':'').'">
				<img src="'.$v['feature_pic_min'].'" alt="'.$v['feature_title'].'"/>
				<p class="title">'.$v['feature_title'].'</p>
				<p>'.$v['feature_intro'].'</p>
				</div>';
		}
		return $str;
	}
		
	/**
	* feature更多功能点
	*/
	function moreFeature( $get )
	{
		$id = $get['产品ID'];
		$p_name = $this->productNameNoBrand( $get );
		
		$str = '';
		$sql = "SELECT f.feature_title,f.feature_intro,f.more_feature_pic FROM feature f
				LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id
				WHERE f.feature_type = 1 AND f.is_delete = 0 AND won_p.id = {$id}
				ORDER BY f.feature_order ASC ";
		$rows = $this->db->getAll($sql);
		
		if( empty( $rows ) ) return '';

		$str .= '<div class="more-features"><h3>'.$p_name.' More Features</h3>';
		foreach( $rows as $k=>$row ){
			$str .= '<div class="cross'.(($k+1)%2==0?' last':'').'">
					<img src="'.$row['more_feature_pic'].'" alt="'.$row['feature_title'].'"/>
					<p class="title">'.$row['feature_title'].'</p>
					<p>'.$row['feature_intro'].'</p>
					</div>';
		}
		$str .= '</div>';
		return  $str;
	}
	
	
	/**
	* 返回右侧留言
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightWord( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT review AS content, username AS user, date FROM product_reviews_detail 
				WHERE pid = '{$id}' AND is_rec = 1";
		$row = $this->db->getOneRs( $sql );
		
		if ( empty( $row['content'] ) ) {
			$sql = "SELECT c.content,c.country,c.user FROM won_product won_p 
					LEFT JOIN comment c ON c.product_id = won_p.won_product_id 
					WHERE won_p.id = '{$id}' AND c.delete = 0 AND c.is_show = 1 AND won_p.won_product_delete = 0
					ORDER BY c.sort ASC LIMIT 1";
			$row = $this->db->getOneRs($sql);
		}
		
		$sql = "SELECT url FROM Table_193 WHERE Field_22043 = '{$id}'";
		$url_reviews = $this->db->getOne($sql);
		
		$url_reviews = url_replace($get['url'] ,$url_reviews, 'iskysoft');

		$str = '';
		if( !empty($row['content'])) {
			$str .= '<div class="side"> 
				<h4>Users Reviews</h4> 
	            <div class="inside">
				<div class="item"> 
	                 <p>'.$row['content'].'<br /> 
	                     <span>- '.$row['user'].'</span></p> 
	               </div> 
	               <div class="item last"> 
	                 <p class="more"><a class="goto" href="'.$url_reviews.'">More Reviews</a></p> 
	               </div></div></div>';
		}
		return $str;
	}

	/**
	 * 右侧bar
	 * */
	function rightBar( $get ){
		
		$str = $this->rightWord( $get );
		if( $str ) return $str;
		
		$id = $get['产品ID'];
		
		//判断是否有bar
		$str = '';
		$sql = "SELECT won_product_guide_bar FROM won_product WHERE id = {$id}";
		$bar = $this->db->getOne($sql);
		
		if( !empty($bar) ){
			$sql = "SELECT block_title,block_content,block_pic_url,block_pic FROM block
					WHERE FIND_IN_SET(block_id,'{$bar}') AND block_delete = 0";
			$rows = $this->db->getAll( $sql );
			
			foreach( $rows as $row ){
				if( $row['block_pic'] ){
					$str_image = '<p class="pic"><a href="'.$row['block_pic_url'].'"><img src="'.$row['block_pic'].'" /></a></p>';
			    }
			   $str .= '<div class="side"><h4>'.$row['block_title'].'</h4>'.$str_image.'<div class="inside">'.$row['block_content'].'</div></div>';
			}
		}
		
		//下面是加载产品右侧广告	
		$sql = "SELECT cat.parent_path 
				FROM won_product won_p 
				LEFT JOIN category cat ON won_p.cat_id = cat.cat_id 
				WHERE won_p.id = '{$id}' ";
	
		$parent_path = $this->db->getOne($sql);
		
		$row = explode(',', $parent_path);
		$father_cat_id = $row[0];//得到一级分类id
		if(!empty($father_cat_id)){
			$sql = "SELECT ad_position.position_size, ad.ad_alt, ad.ad_photo, ad.ad_url,ad_position.position_name, ad.ad_name 
					FROM ad_delivery, ad, ad_position 
					WHERE ad_delivery.position_id = 52 AND ad_delivery.ws_id = '{$id}' AND ad_delivery.cat_id = '{$father_cat_id}' 
					AND ad_delivery.position_type =5 AND ad_delivery.ad_web = 8 AND ad_delivery.is_text_ad = 0 
					AND ad_position.position_id = ad_delivery.position_id AND ad_delivery.ad_id = ad.ad_id LIMIT 1";				
			$rows = $this->db->getAll($sql);
	
			if(!empty($rows)){
			  $row_size = explode('*',$rows[0]['position_size']);
			  $ad_url = $rows[0]['ad_url'].'?icn='.$rows[0]['ad_name'].'&ici='.$rows[0]['position_name'];
			  
			  $str = '<div class="banner">
			  		 <a href="'.$ad_url.'">
			  		 <img src="'.$rows[0]['ad_photo'].'"   alt="'.$rows[0]['ad_alt'].'" width="'.$row_size[0].'" height="'.$row_size[1].'" />
			  		 </a></div>'.$str;
			}
		}
		return  $str;
	}

	/**
	* 产品页面右侧视频bar
	*/
	function rightVideoBar( $get )
	{
		//当页面的其它位置显示了同一视频，则在右侧不再显示该视频，在iskysoft中有用到
		if( $this->video_tag == 'VideoOff' ) return '';
		
		$id = $get['产品ID'];


		$sql = "SELECT p.product_video_promo,p.product_name FROM won_product won_p
				LEFT JOIN product p ON p.product_id = won_p.won_product_id
				WHERE id = {$id}";
		$row = $this->db->getOneRs( $sql );
		
		if( empty($row['product_video_promo']) ) return '';

		$row = $this->productInfo( $id );
		$os = $row['product_os'];
		
		$str = '<div class="side video">
				<h4>Watch the Video</h4>
				<div class="inside">
				<div class="flash videoDemo" href="#video-demo">
				<img class="pic" src="http://images.iskysoft.com/images/screencast/'.($os=='Win'?'sc-win':'sc').'.jpg" />
				</div></div></div>';

		return  $str;
	}
	
	/**
	* 根据产品id取产品页面右侧视频弹出html
	*/
	function rightVideoPopup( $get )
	{
		$id = $get['产品ID'];
		$video = parent::rightVideoPopup( $id, 'iskysoft' );

		$str = '<link rel="stylesheet" type="text/css" href="http://images.iskysoft.com/js/fancybox-2.0.5.css" media="screen" />';
		$str .= '<script type="text/javascript" src="http://images.iskysoft.com/js/fancybox-2.0.5.js?v=2.0.5"></script>';
		$str .= $video;
		return $str;
	}
			
	/**
	* 根据产品id取产品页面tips右侧
	*/
	function rightTips( $get )
	{	
		$id = $get['产品ID'];
		
		$sql = "SELECT tips FROM won_product WHERE id = {$id}";
		$tips = $this->db->getOne($sql);
		
		if( empty( $tips ) ) return '';

		$str = '<div class="side articles">
				<h4>Guides &amp; Tutorials</h4>
		        <div class="inside"><ul>'.$tips.'</ul></div>
		        </div>';
		 return $str;
	}

	/**
	* 根据产品id获取对应的win或者max产品
	*/
	function relWinMac( $get )
	{
		$id = $get['产品ID'];
		
		$str = '';
		$sql = "SELECT p.product_os,p.product_rel,p.product_name FROM won_product won_p LEFT JOIN product p ON p.product_id = won_p.won_product_id WHERE id = {$id}";
		$ret = $this->db->getOneRs($sql);
		
		if( empty($row['product_rel']) ) return '';
		
		
		$sql = "SELECT tab.url, tab.Field_21670 AS p_name, p.product_os FROM won_product AS won_p 
				LEFT JOIN Table_137 AS tab ON won_p.id = tab.Field_21669
				LEFT JOIN product AS p ON p.product_id = won_p.won_product_id
				WHERE won_p.won_product_id = {$ret['product_rel']}";
		$row = $this->db->getOneRs( $sql );
		
		//单页
		if( empty($row['url']) ){
			$sql = "SELECT tab.url, tab.Field_21727 AS p_name, p.product_os FROM won_product AS won_p 
					LEFT JOIN Table_147 AS tab ON won_p.id = tab.Field_21726
					LEFT JOIN product AS p ON p.product_id = won_p.won_product_id
					WHERE won_p.won_product_id = {$ret['product_rel']}";
			$row = $this->db->getOneRs( $sql );
		}

		$url  = $row['url'];
		$url = url_replace($get['url'],$url ,'iskysoft');
		$p_name = $row['p_name'];
		$os = $ret['product_os'];
		
		if( $os == 'Win'){
			$p_name .= ' for Windows';
		}elseif( $os == 'Mac' ){}
		
		$str = '<span>Note:</span> '.($os == 'Win' ? 'Windows' : 'Mac').' version is also available, <a class="goto" href="'.$url.'">get '.$p_name.' here</a>';
		return $str;
	}
	
	/**
	* lion图片地址
	*/
	function lionPicUrl( $get )
	{	
		$id = $get['产品ID'];		
		$sql = "SELECT lion_url FROM won_product WHERE id = {$id}";
		$lion_url = $this->db->getOne($sql);
		
		$str = '';
		if( !empty( $lion_url ) ) $str = trim($lion_url);
		return $str;
	}

	/**
	 * 面包屑
	 * */
	function bread( $get ){
		$id = $get['产品ID'];

		$p_name = $this->productNameHadOs( $get );
		
		$row = $this->productInfo( $id );
		$os = $row['product_os'];

		$str = '<a href="'.($os=='Win'?'http://www.iskysoft.com/products-windows.html':'http://www.iskysoft.com/products-mac.html').'">'.
				($os=='Win'?'Windows':'Mac').' Products</a> <big>»</big>'.$p_name;
		return $str;
	}
	
	/**
	* 根据产品ID及切换名称取切换内容
	*/
	function switchContent( $get )
	{
		$id = $get['产品ID'];
		$tab_name = $get['产品切换名称'];
		
		$sql = "SELECT id FROM product_attributes WHERE web_type = 8 AND name = '{$tab_name}'";
		$tab_id = $this->db->getOne( $sql );
		if( !empty($tab_id) )
		{
			$sql = "SELECT page_content FROM product_page WHERE product_id = {$id} AND article_id = {$tab_id}";
			$page_content = $this->db->getOne( $sql );
		}
		return $page_content ? $page_content : '';
	}
	
	
	/**
	* 返回页面当前地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function currentUrl( $get ){
		$url = str_replace(array('index.html','/iskysoft.com/httpdocs/'),array('','http://www.iskysoft.com/'),$get['url']);
		return $url;
	}
	
	/**
	* 返回跟踪url
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function followingUrl($get) {
		$url = str_replace(array('index.html', '/iskysoft.com/httpdocs/'), 
							array('', 'http://www.iskysoft.com/'), $get['url']);
		$url = 'addthis:url="'.$url.'"';	
		return $url;
	}
	
	//note 评论信息
	function reviews( $get ) {
		$id = $get['产品ID'];
		
		$sql = "SELECT url FROM Table_193 WHERE Field_22043 = '{$id}'";
		$url_reviews = $this->db->getOne($sql);
		
		if( empty($url_reviews) ) {
			return '';
		}

		$url_reviews = url_replace($get['url'],$url_reviews ,'iskysoft');
		
		$str = parent::reviews( $id, $url_reviews );
		return $str;
	}
	
	//note 写评论地址
	function reviewsWriteUrl($get) {
		$id = $get['产品ID'];
		$product_brand = $this->productBrand($get);
		
		$str = 'http://www.iskysoft.com/reviews/reviews-write.html';
		$str .= '?pid='.$id;
		$str .= '&p='.$product_brand;
		
		$row = parent::productInfo( $id );
		
		$str .= '&n='.urlencode($row['product_name']);
		
		if ( $row['product_os'] == 'Win' ) {
			$str .= '&os=Windows';
		} else if($row['product_os'] == 'Mac' ) {
			$str .= '&os=Mac';
		}
		
		return $str;	
	}
	
	/**
	* 最后一条产品评论以及作者
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productLastReviews($get) {

		$str = '';

		$rows = parent::productLastReviewsInfo($get);
		
		if (!empty($rows)) {
			
			$str = 
			'<div class="info">
            <strong>'.$get['产品名称'].' users review</strong>
            <div class="img"><img src="http://images.iskysoft.com/style/images/good_03.png" /></div>
            ';
			
			$str .= '<p>'.$rows['review'].'</p><span class="fr">————'.$rows['username'].'</span></div>';
		}
		
		return $str;
		
	}
	
	/**
	* 产品价格前台显示
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productPriceShow($get) {

		$str = '';
		$arr = parent::productPriceOldAndCurr($get);//得到价格信息
		
		$str = '<strong class="price">'.$arr['curr'].'</strong> <del>'.$arr['old'].' </del>' ;
		return $str;	
	}
	
	
	/**
	* 下载跳转步骤
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function downloadJumpSteps($get) {

		$str = '';
		if ($get['选择类型'] == 1 ) { //代表为Win类型
			
			$str = '<div class="box1">
					<div class="item">
					<span class="num">1.</span>
					<p>Depending on your connection speed, the download may take up to a few minutes.</p>
					<img src="http://images.iskysoft.com/images/download-pop/win1.jpg">
					</div>
					<div class="item">
					<span class="num">2.</span>
					<p>The Product setup wizard will be launched.</p>
					<img src="http://images.iskysoft.com/images/download-pop/win2.jpg">
					</div>
					<div class="item">
					<span class="num">3.</span>
					<p>Double-click the software icon to open the application.</p>
					<img src="http://images.iskysoft.com/images/download-pop/win3.jpg">
					</div>
					</div>';
			
		} else if($get['选择类型'] == 2) {//代表为Mac类型
			
			$str = '<div class="box1">
					<div class="item">
					<span class="num">1.</span>
					<p>Double-click the .DMG file to open it up and a Finder window will appear.</p>
					<img src="http://www.iskysoft.com/images/download-pop/process_07.jpg">
					</div>
					<div class="item">
					<span class="num">2.</span>
					<p>Double-click the .DMG file to open it up and a Finder window will appear.</p>
					<img src="http://www.iskysoft.com/images/download-pop/process_09.jpg">
					</div>
					<div class="item">
					<span class="num">3.</span>
					<p>Double-click the software icon to open the application.</p>
					<img src="http://www.iskysoft.com/images/download-pop/process_11.jpg">
					</div>
					</div>';
		}

		return $str;
		
	}
	
	/**
	* 产品购买地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productBuyUrl($get) {

		
		$id = (int) $get['产品ID'];
		$url = '';
		
		$sql = "SELECT url FROM Table_168 WHERE Field_21835 = {$id} LIMIT 1 ";
		$url = $this->db->getOne($sql);

		$url = url_replace($get['url'], $url, 'iskysoft');
		
		return $url;
	}
	/**
	* 产品下载跳转地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productPopUrl($get) {

		
		$id = (int) $get['产品ID'];
//		$url = '';
//		
//		$sql = "SELECT url FROM Table_197 WHERE Field_22071 = {$id} LIMIT 1 ";
//		$url = $this->db->getOne($sql);
//
//		$url = url_replace($get['url'], $url, 'iskysoft');
		return  parent::productDownLoadUrl($get);
//		return $url ? $url : parent::productDownLoadUrl($get);
	}
	
	/**
	* 绑定相关产品
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function bindingRelatedProduct($get) {

		$str = '';
		$result = parent::bindingRelatedProductInfo($get);
		if (empty($result)) {
			return '';
		}
		
		$i = 0;
		while ($row = $this->db->fetch_array($result)) {
			
			if ($row['product_type'] == 1) { //是否试用
				
				$get['产品ID'] = $row['id'];
				$product_url = $this->productUrl($get);//得到产品url
				$downLoad_url = parent::productDownLoadUrl($get);//得到产品下载链接
				
				if ($i != 0 ){
					$str .= '<div class="item">';
				}
				$str .=  
				'<div class="img"><a href="'.$product_url.'"><img src="'.$row['product_box_middle'].'" /></a></div>
                <h3><a href="'.$product_url.'">'.$row['product_name'].'</a></h3>
                <p>'.$row['product_intro'].'</p>
                <a href="'.$downLoad_url.'" 
                onclick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]);
                _gaq.push([\'_trackPageview\', this.href]);setTimeout(function(){location.href=that.href;},100);return false;" class="trialBtn" target="_blank" >Free Trial</a>
            	</div>';
				$i = $i + 1;
			}
		}
		
		$get['产品ID'] = $id;
		
		$str_before = ' <h2>Customers who liked '.$get['产品名称'].', also bought:</h2> <div class="box3">';
		
		if( $i > 1) {
			$str = $str_before.'<div class="item borR">'.$str.'</div>';
		} else if($i == 1) {
			$str = $str_before.'<div class="item">'.$str.'</div>';
		}else {
			return '';
		}
		
		unset($row);
		return $str;
	}
	
	/**
	* 得到评论列表和分页信息 
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function reviewsCreatePage($get = array() ) {
		
		$id = $get['产品ID'];
		
		$DirName = dirname($get['url']);
		$dirurl = str_replace('/iskysoft.com/httpdocs/','',$DirName);
		//不预览
		$template_str = $this->replaceTemplateAndGet($get['tem_style']);
		$get['do'] = isset($get['do']) ? $get['do'] : '';
		if ( $get['do'] != 'view') {
			
			$dir = DOC_ROOT.'/'.$DirName;
			MakeDir1($dir);
			
			if (!is_dir($dir)) {
				$DirName = DOC_ROOT.'/iskysoft.com/httpdocs';
			}
		}
		
		$sql = "SELECT * FROM product_reviews_detail WHERE pid = '{$id}' AND check_state = 1 ORDER BY `date` DESC";
		$all = $this->db->getAll($sql);
		
		/************************* 全部 ********************************************/
		$total = count($all);
		$max_page = ceil($total / 10);
		for ($i = 1; $i <= $max_page; $i++) {
		
			$temp = $template_str;
			$page_start = ($i - 1) * 10 + 1;
			$page_end = ($i - 1) * 10 + 10;
			
			if( $page_end >= $total) {
				$page_end = $total;
			}
			
			$list = '';
			$chang_sum = 0;
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break; 	
				}  
			
				$list .= '<div class="reviewsItem">
				<div  class="rating">
				<ul>
				<li '.($all[$j]['star'] >= 1 ? 'class="on"' : '').'><a href="javascript:;">1</a></li>
				<li '.($all[$j]['star'] >= 2 ? 'class="on"' : '').'><a href="javascript:;">2</a></li>
				<li '.($all[$j]['star'] >= 3 ? 'class="on"' : '').'><a href="javascript:;">3</a></li>
				<li '.($all[$j]['star'] >= 4 ? 'class="on"' : '').'><a href="javascript:;">4</a></li>
				<li '.($all[$j]['star'] >= 5 ? 'class="on"' : '').'><a href="javascript:;">5</a></li>
				</ul>
				</div>
				<strong class="title">'.str_replace(array("\\","\r\n"),array('','<br/>'),$all[$j]['title']).'</strong><br/>
				<span class="info">'.$all[$j]['username'].' | '.$all[$j]['date'].'</span>
				<div class="clear"></div>
				
				<p class="con">'.str_replace(array("\\","\r\n"),array('','<br/>'),$all[$j]['review']).'</p>
				
				<div class="ud"><a href="javascript:s_o('.$all[$j]['did'].',1);" class="up"></a>
				<span class="fl" id="support_'.$all[$j]['did'].'">'.$all[$j]['support'].'</span>
				<a href="javascript:s_o('.$all[$j]['did'].',2);" class="down"></a><span class="fl" id="oppose_'.$all[$j]['did'].'">'.$all[$j]['oppose'].'</span></div>
				<div class="addthis_toolbox addthis_default_style share fr"> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a></div>';
				
				if( !empty($all[$j]['reply']) ) {
					$list .= '<div class="clear"></div><p class="reply"><strong>Iskysoft:</strong><br />'.$all[$j]['reply'].'</p>';
				}
				
				$list .= '<div class="btm"></div></div>';
			}
		
			//分页
			$page = '<div class="paging">';
			if ( $i  > 1 ) {
				if($i -1 == 1){
				$page .= '<a href="'.'../../'.$dirurl.'/" class="prev">Prev</a>';
				}else{
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i-1).'.html" class="prev">Prev</a>';
				}
			} else {
				$page .= '<a class="prev">Prev</a>';
			}
		
		
			$start = $i - 4;
			$end = $i + 4;
			if ($start < 1) {
				$start = 1; $end = 6;
			}
			
			if ($end > $max_page) {
				$end = $max_page; $start = $max_page - 5;
			}
			
			if ($start < 1) {
				$start = 1;
			}
			
			if ($start != 1) {
				$output .= '';	
			}
			
			for ($start; $start <= $end; $start++) {
				
				if ($i == $start) 
				{
					$page .= '<strong>'.$start.'</strong>';
				} else {
					if ($start == 1) {
						$page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
					}
				}
			}
			
			if ($end != $max_page) {
				$output .= '';
			}
			if ($i < $max_page) {
				$page .= '<a href="'.'../../'.$dirurl.'/'.($i+1).'.html" class="next">Next</a>';
			} else  {
				$page .= '<a class="next">Next</a>';
			}
		
			if ( $total == 0 ) {
				$page = '<div class="paging">';	
			} 
		
			$page = $list.$page.'</div>';

			if (isset($get['do']) && $get['do'] == 'view') {
				return $page;
			}
			
			
			$temp = str_replace("<!--page_module-->", $page, $temp);
			$temp = str_replace('$'.'{评论列表和分页信息}', '', $temp);
			$temp = str_replace('$'.'{页面关键字生成}', $this->titleCreate($get), $temp);
			$temp = str_replace('$'.'{页面描述生成}', $this->descriptionCreate($get), $temp);
			$temp = str_replace('$'.'{页面title生成}', $this->titleCreate($get).' of '.$i, $temp);

			$temp = str_replace('$'.'{加系统产品名称}', $this->productNameHadOs($get),$temp);
			$temp = str_replace('$'.'{产品切换列表}', $this->switchPage($get), $temp);
			$temp = str_replace('$'.'{下载与免费上}', $this->downloadAndPriceTop($get), $temp);
			$temp = str_replace('$'.'{评论信息}', $this->reviews($get), $temp);
			$temp = str_replace('$'.'{写评论地址}', $this->reviewsWriteUrl($get), $temp);
			$temp = str_replace('$'.'{右侧bar}', $this->rightBar($get), $temp);
			$temp = str_replace('$'.'{右侧视频bar}', $this->rightVideoBar($get), $temp);
			$temp = str_replace('$'.'{右侧tips}', $this->rightTips($get), $temp);
			$temp = str_replace('$'.'{右侧视频弹出html}', $this->rightVideoPopup($get), $temp);
		
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			
			$str_link  = '';
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == 1 ) {
			
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i > 1 && $i < $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == $max_page) {
				
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}
			
			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			}else{
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}
		}
	}
	
	//note 版本列表
	function versionList( $get ){
		$id = $get['产品ID'];
		$p = $this->productInfo( $id );
		
		if( empty($p) ) return '';
		
		$product_id = $p['product_id'];
		
		$sql = "SELECT version_name, publish_date, whatisnew_title, whatisnew_content FROM version 
				WHERE product_id = '{$product_id}'
				ORDER BY version_id DESC";
		$rows = $this->db->getAll( $sql );
		
		$str = '';
		foreach( $rows as $k=>$row ){
			
			if( $k == 9 ){
				$str .= '<p class="show"><a onclick="openShutManager(this,\'box1\',false,\'Show less...\',\'Show more...\')">Show more...</a></p>';
			}
	
			if( $k == 9 ) $str .= '<div id="box1" style="display:none">';
			
			$str .= '<div class="item">
				<h3>'.$row['whatisnew_title'].' <span>'.date('F j, Y', strtotime( $row['publish_date'] )).'</span></h3>
				<ol>';
			
			$row['whatisnew_content'] = str_replace(array("What's new：\r\n","What’s new:\r\n"), array('',''), $row['whatisnew_content']);
			$arr = explode("\r\n", $row['whatisnew_content']);
			foreach( $arr as $v ){
				$str .= '<li>'.$v.'</li>';
			}	
			    
			$str .= '</ol></div>';
		}
		
		if( $k >= 9 ) $str .= '</div>';
		
		return $str;
	}
	
	//note 产品下载分类列表
	function productDownloadCatList( $get )
	{
		$product_os = $get['产品类型'] == 1 ? 'Win' : 'Mac'; 
	
		$sql_cat ="
		SELECT `cat_id`,`cat_title` FROM `category` WHERE `cat_web`=8 AND `cat_type`=2 AND `cat_series`=3 AND `is_delete`=0 and `cat_id` in
		 (
			SELECT cat_id
			FROM won_product AS won
			LEFT JOIN product AS p ON won.`won_product_id` = p.`product_id`
			WHERE p.product_os = '".$product_os."'
			AND p.`product_delete`=0
			AND won.`web_type` =8
			AND won.`won_product_delete` =0
			GROUP BY won.cat_id
		)";
		$array_cat = array();
		$array_product = array();
		$result_cat = $this->db->query($sql_cat);
		while($rs_cat = $this->db->fetch_array($result_cat))
		{
			$array_cat[$rs_cat['cat_title']] = $rs_cat['cat_id'];
		}
	
		foreach($array_cat as $key=>$val)
		{
			$sql ="
			SELECT won.`id`,p.`product_id`,p.`product_icon_max`,p.`product_name`,p.product_brand,p.product_ad
			FROM `won_product` AS won
			LEFT JOIN `product` AS p ON won.won_product_id = p.product_id
			WHERE p.`product_os`='".$product_os."' AND won.`web_type` =8 AND won.`won_product_delete`=0
			AND won.`cat_id` = ".$val."
			";
			$result = $this->db->query($sql);
			while($rs = $this->db->fetch_array($result))
			{
				
				$url_product = $this->db->getOne("select `url` from `Table_137` where `Field_21669`=".$rs['id']);
				if(!$url_product)
				{
					$url_product = $this->db->getOne("select `url` from `Table_147` where `Field_21726`=".$rs['id']);
				}
				if(!$url_product) continue;
				$url_product = str_replace('/iskysoft.com/httpdocs','http://www.iskysoft.com',$url_product);
				$get['产品ID']=$rs['id'];
				
				$version = get_sale_version($rs['product_id']);
				$downloadUrl = $version['download_url'];

				$size = $this->db->getOne("select `product_size` from `version` where `product_id`={$rs['product_id']} and `is_sale`=1 limit 1");
				if(!$size)
				{
					$size = getFileSize(parent::productDownLoadUrl($get));
					$this->db->query("update `version` set `product_size`={$size} where `product_id`={$rs['product_id']} and `is_sale`=1");
				}
				$array_product[$key][] = array('product_icon_max'=>$rs['product_icon_max'],'product_brand'=>$rs['product_brand'],'product_name'=>$rs['product_name'],'product_ad'=>$rs['product_ad'],'url'=>$url_product,'downloadUrl'=>$downloadUrl,'size'=>$size);
			}
		}
		$str='';
		foreach($array_product as $key=>$array)
		{
			if(stripos($key,'DVD Tools')!==false)
			{
				$icon="http://images.iskysoft.com/images/tutorial/ripmanage/managedvd.png";
			}
			elseif(stripos($key,'Video Tools')!==false)
			{
				$icon="http://images.iskysoft.com/images/tutorial/icon-video.png";
			}
			elseif(stripos($key,'iPod/iPhone/iPad')!==false)
			{
				$icon="http://images.iskysoft.com/images/tutorial/icon-iphone.png";
			}
			elseif(stripos($key,'PDF Tools')!==false)
			{
				$icon="http://images.iskysoft.com/images/tutorial/icon-pdf.png";
			}	
		   $str.=' 
			<div class="title">
				<h2><img src="'.$icon.'" /> '.$key.'</h2>
			</div>
			<table cellpadding="0" cellspacing="0"  class="listTable">
			  <thead>
			  <tr>
				<th width="470">Product</th>
				<th width="215">Download</th>
				<th width="215">Size</th>
			  </tr>
          </thead>';
		  foreach($array as $key=>$list)
		  {
            $str.='
			  <tr>
				  <th><div class="img"><img src="'.$list['product_icon_max'].'" height="40" width="40" /></div>
					<strong><a href="'.$list['url'].'">'.$list['product_brand'].str_replace('iSkysoft',' ',$list['product_name']).'</a></strong><br />
					<p>'.$list['product_ad'].'</p>
				  </th>
				<td><a href="'.$list['downloadUrl'].'" class="downGay">Free Trial</a></td>
				<td>'.$list['size'].'MB</td>
              </tr>';
		  }
			$str.='</table>';
		}
		return $str;
	}
}
?>